package com.zz.cc.owner.app;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler.Callback;
import android.os.Message;

import com.zz.cc.owner.R;
import com.zz.common.app.BaseActivity;
import com.zz.common.tools.WeakReferenceHandler;

public class StartUpActivity extends BaseActivity implements Callback {
	
	private static final int ACTION_START_UP_FINISH = 100;
	private static final int PERIOD_START_UP = 1000;
	
	private WeakReferenceHandler mHandler;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mHandler = new WeakReferenceHandler(this);
		setContentView(R.layout.activity_start_up);
		mHandler.sendEmptyMessageDelayed(ACTION_START_UP_FINISH, PERIOD_START_UP);
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		mHandler.removeMessages(ACTION_START_UP_FINISH);
	}

	@Override
	public boolean handleMessage(Message msg) {
		if(msg.what == ACTION_START_UP_FINISH) {
			startNextActivity();
		}
		return true;
	}
	
	private void startNextActivity() {
		Intent intent = new Intent(this, UserGuideActivity.class);
		startActivity(intent);
		finish();
		overridePendingTransition(R.anim.activity_slide_right_in, R.anim.activity_slide_left_out);
	}

}
